$(function () {
    resourceTable();
});
function resourceTable() {
    $('#resource_table').bootstrapTable({
        url: ctx+ '/security/resource',         //请求后台的URL（*）
        method: 'get',                      //请求方式（*）
        toolbar: '#toolbar',                //工具按钮用哪个容器
        striped: true,                      //是否显示行间隔色
        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true,                   //是否显示分页（*）
        sortable: true,                     //是否启用排序
        sortOrder: "asc",                   //排序方式
        queryParams: resourceTable.queryParams,//传递参数（*）
        sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
        pageNumber:1,                       //初始化加载第一页，默认第一页
        pageSize: 2,                       //每页的记录行数（*）
        pageList: [2, 20, 30, 50],        //可供选择的每页的行数（*）
        search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: true,
        showColumns: false,                  //是否显示列选择器
        showRefresh: false,                  //是否显示刷新按钮
        minimumCountColumns: 0,            //最少允许的列数
        toolbarAlign: 'right',
        clickToSelect: true,                //是否启用点击选中行
        height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
        uniqueId: "id",                     //每一行的唯一标识，一般为主键列
        showToggle:false,                    //是否显示详细视图和列表视图的切换按钮
        cardView: false,                    //是否显示详细视图
        detailView: false,                   //是否显示父子表
        checkboxHeader: true,
        showFooter: false,
        paginationLoop: false,
        undefinedText: '',
        columns: [
            [
                {
                    field:'serialNumber',
                    title:'No.',
                    valign:"middle",
                    align:"center",
                    colspan:1,
                    rowspan:3,
                    width:"4%"
                },
                {
                    field:'productionName',
                    title:'品番',
                    valign:"middle",
                    align:"center",
                    colspan:1,
                    rowspan:3,
                    width:"8%"
                },
                {
                    field:'n',
                    title:'N',
                    valign:"middle",
                    align:"center",
                    colspan:1,
                    rowspan:3,
                    width:"8%"
                },
                {
                    title:'发泡实绩',
                    halign:"center",
                    align:"center",
                    colspan:8,
                    width:"56%"
                },
                {
                    title:'PCS',
                    halign:"center",
                    align:"center",
                    colspan:4,
                    width:"24%"
                }
            ],
            [
                {
                    title:'1班',
                    halign:"center",
                    align:"center",
                    colspan:2,
                    width:"14%"
                },
                {
                    title:'2班',
                    halign:"center",
                    align:"center",
                    colspan:2,
                    width:"14%"
                },
                {
                    title:'3班',
                    halign:"center",
                    align:"center",
                    colspan:2,
                    width:"14%"
                },
                {
                    title:'合计',
                    halign:"center",
                    align:"center",
                    colspan:2,
                    width:"14%"
                },
                {
                    field:'pcs1',
                    title:'1班',
                    valign:"middle",
                    align:"center",
                    colspan:1,
                    rowspan:2,
                    width:"6%"
                },
                {
                    field:'pcs2',
                    title:'2班',
                    valign:"middle",
                    align:"center",
                    colspan:1,
                    rowspan:2,
                    width:"6%"
                },
                {
                    field:'pcs3',
                    title:'3班',
                    valign:"middle",
                    align:"center",
                    colspan:1,
                    rowspan:2,
                    width:"6%"
                },
                {
                    field:'pcsSum',
                    title:'合计',
                    valign:"middle",
                    align:"center",
                    colspan:1,
                    rowspan:2,
                    width:"6%"
                }
            ],
            [
                {
                    field:'injectNumber1',
                    title:'注入数',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                },
                {
                    field:'pass1',
                    title:'PASS',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                },
                {
                    field:'injectNumber2',
                    title:'注入数',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                },
                {
                    field:'pass2',
                    title:'PASS',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                },
                {
                    field:'injectNumber3',
                    title:'注入数',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                },
                {
                    field:'pass3',
                    title:'PASS',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                },
                {
                    field:'injectNumberSum',
                    title:'枚',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                },
                {
                    field:'passSum',
                    title:'PASS',
                    valign:"middle",
                    align:"center",
                    width:"7%"
                }
            ]
        ],
        onCheck: function (row) {
            var a= $('#resource_table').bootstrapTable('getSelections');
            console.log(a);
        }
    });
}

resourceTable.queryParams = function (params) {
    return {
        pageSize: params.limit,   //页面大小
        curPage: params.offset  //页码
    };
};

function addResource() {
    $('body').append("<div class=\"modal fade\" id=\"resourceAddModal4\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"resourceAddModal\">"
    + "<div class=\"modal-dialog\" role=\"document\">"
    + "<div class=\"modal-content\">"
    + "</div>"
    + "</div>"
    + "</div>");
    $('#resourceAddModal4').modal({backdrop: 'static', keyboard: false, remote:ctx+'/security/login'});
}



